<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title> - 地区数据- </title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<!--<link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__STATIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
	<link href="__STATIC__/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/css/new_file.css" rel="stylesheet">-->
	<link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css" rel="stylesheet">
	<link href="__STATIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
	<link href="__STATIC__/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/css/new_file.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox ">
				<div class="ibox-title">
					<h5>地区数据</h5>
				</div>
				<div class="toogl_body">
					<div class="toogl_tale">
						<a href="regionaldata"><input type="button" value="每日概况" class="btn btn-w-m btn-info"></a>
						<a href="regionaldata_2"><input type="button" value="地区总数" class="btn btn-w-m btn-default"></a>
					</div><br/>
					<div class="ibox-content ibox-jqGrid">
						<p>
							时间：<input type="text" class="input-ys" readonly="readonly" id="time">
							地区： <select class="input-ys" id="area">
							        <option value="">请选择地区</option>
							        <!--<option value="2">天津</option>   -->
							    </select> 
							<input type="button" value="确定" class="input-anniu" id="buttonid">
							<span id="count"></span>
						</p>
						<div class="jqGrid_wrapper">
							<table id="table_list_1"></table>
							<div id="pager_list_1"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!--手机导航-->
<div class="to-fdh" style="display: none;">
	<img class="to-imgd" src="__STATIC__/img/phonedh.jpg">
	<div class="mob-nrlb">
		<ul>
			<li>
				<a class="mob-nrdh">管理</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('Player/gameplayer')}">玩家管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('system/notice')}">公告管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('email/mail')}">邮件管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Club/club')}">亲友圈管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Money/money')}">提现管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Order/order')}">订单管理</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="mob-nrdh">数据</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('data/datagk')}">概況</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datawf')}">玩法</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datalc')}">留存</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datass')}">实时数据</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/dataczfx')}">充值分析</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/dataclub')}">亲友圈统计</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/president')}">高级会长</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/regionaldata')}">地区数据</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="mob-nrdh mob-qbh">权限</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('rule/rule_list')}">权限管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('rule/rule_group')}">用户组管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('account/account_details')}">后台账号管理</a>
					</li>
				</ul>
			</li>
		</ul>
	</div>
</div>
<div class="vnl-zz" style="display:none">
	<div><img src="__STATIC__/img/bqhp.gif"></div>
</div>
<!--手机适配-->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/peity/jquery.peity.min.js"></script>
<script src="__STATIC__/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
<script src="__STATIC__/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
<script src="__STATIC__/js/content.js?v=1.0.0"></script>
<script src="__STATIC__/js/plugins/laydate/laydate.js"></script>
<script src="__STATIC__/js/echarts.min.js"></script>
<script src="__STATIC__/js/echarts.common.min.js"></script>
<script>
    //手机适配
    $(function(){
        if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
            $("head").append("<link>");
            var css = $("head").children(":last");
            css.attr({
                rel:  "stylesheet",
                type: "text/css",
                href: "__STATIC__/css/phone_sp.css"
            });
            var mql = window.matchMedia("(orientation: portrait)");
            if(mql.matches) { //竖屏样式
                $(".vnl-zz").show();
                $(".to-fdh").hide();
            }else{
                $(".to-fdh").show();
                $("html").width("100%");
                $("body").width("100%");
            }
            mql.addListener(function(m) {
                if(m.matches) {
                    // 改变到直立方向
                    $(".vnl-zz").show();
                    $(".to-fdh").hide();
                }
                else {
                    $(".to-fdh").show();
                    $(".vnl-zz").hide();
                    $("html").width("100%");
                    $("body").width("100%");
                }
            });
        }
    });
    //导航显示展开
    $(".mob-nrdh").click(function(){
        $(this).next().toggle(".mob-nryc");
    });
    $(".to-imgd").click(function(){
        $(this).next().toggle(".mob-nrlb");
    });
    //手机适配end<script>
	var mydata =[];
	//獲取七天前的數據
    function get7DaysBefore(date){
        var _date = new Date(); //获取今天日期
        _date.setDate(_date.getDate() - 7);//日期回到七天前
        var year=_date.getFullYear();
        var month=_date.getMonth()+1;
        var day=_date.getDate();
        if (month<10) {
            month='0'+month;
        };
        if (day<10) {
            day='0'+day;
        };

        var dateTemp = year+'-'+month+'-'+day;
        _date.setDate(_date.getDate() + 7);//日期重置
        return dateTemp;
    }
    //獲取當前的數據
    function getDaysBefore(date){
        var _date=new Date();
        var year=_date.getFullYear();
        var month=_date.getMonth()+1;
        var day=_date.getDate();
        if (month<10) {
            month='0'+month;
        };
        if (day<10) {
            day='0'+day;
        };
        return year+'-'+month+'-'+day;
        // return [[newDate.getFullYear(), newDate.getMonth() + 1, newDate.getDate()].join('-'), [newDate.getHours(), newDate.getMinutes(), newDate.getSeconds()].join(':')].join(' ');
    }
    //玩家所属亲友圈
    $(function() {
        $.ajax({
            type: "post",
            url: "{:url('account/Area')}",
            data: {},
            dataType: "json",
            success: function(e) {
                console.log(e);
                for(i in e) {
                    $("#area").append("<option value='" + e[i].aid + "'>" + e[i].area_name + "</option>");
                }
            },
            error: function(e) {
                console.log(e);
            }
        });
    });
    function DateDiff(sDate1, sDate2) {  //sDate1和sDate2是yyyy-MM-dd格式

        var aDate, oDate1, oDate2, iDays;
        aDate = sDate1.split("-");
        oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);  //转换为yyyy-MM-dd格式
        aDate = sDate2.split("-");
        oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);
        iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24); //把相差的毫秒数转换为天数

        return iDays;  //返回相差天数
    }
    $('#buttonid').on('click', function() {     //页面上的button按钮的click事件，重新获取参数后发送参数，然后重新加载数据。

        var time = $("#time").val();
        var area =  $("#area").val();
        if(time == ""){
            alert("请选择日期");
            return false;
        }
        if(area == ""){
            alert("请选择地区");
            return false;
        }
        // var start_time = time.substring(0,10)+" "+"00:00:00";
        // var end_time = time.substring(13)+" "+"23:59:59";
        var start_time = time.substring(0,10);
        var end_time = time.substring(13);
        var day = DateDiff(start_time,end_time)+1;
        // $("#table_list_1").jqGrid('setGridParam',{
        //     url:'__URL__/area_data',
        //     datatype:'json',
        //     postData:{'start_time':start_time,'end_time':end_time,'area':area},
        //     page:1
        // }).trigger("reloadGrid"); //重新载入
        $.ajax({
            url: '__URL__/area_data',
            data: {
                "start_time": start_time, //开始日期
                "end_time":end_time, // 结束日期
                'area':area,
            },
            dataType: "json",
            type: "post",
            success: function(e) {
                var pay_gold_num = 0;
                var free_gold_num = 0;
                var club_recharge_card_amount = 0;
                var create_room_num = 0;
                var recharge_diamond_amount = 0;
                $("#table_list_1").jqGrid("clearGridData");
                for(i  in e ){

                    mydata = {
                        datetime: e[i].datetime, //时间
                        day_added_user: e[i].day_added_user,
                        day_active_user: e[i].day_active_user,
                        create_room_num: e[i].create_room_num,
                        create_room_num_region_detail: e[i].create_room_num_region_detail,
                        finish_room_num: e[i].finish_room_num,
                        day_active_user_region_detail: e[i].day_active_user_region_detail,
                        valid_active_user_region_detail: e[i].valid_active_user_region_detail,
                        create_club_num: e[i].create_club_num,
                        dissolve_club_num: e[i].dissolve_club_num,
                        reduce_free_gold_num: e[i].reduce_free_gold_num,
                        reduce_pay_gold_num: e[i].reduce_pay_gold_num,
                        club_recharge_card_amount: e[i].club_recharge_card_amount,
                        recharge_diamond_amount: e[i].recharge_diamond_amount,


                    };
                    $("#table_list_1").addRowData(i, mydata, "last");
                    var pay_gold_num = pay_gold_num+parseInt(e[i].reduce_pay_gold_num);
                    var free_gold_num = free_gold_num+parseInt(e[i].reduce_free_gold_num);
                    var club_recharge_card_amount = club_recharge_card_amount+parseFloat(e[i].club_recharge_card_amount);
                    var create_room_num = create_room_num+parseInt(e[i].create_room_num);
                    var recharge_diamond_amount = recharge_diamond_amount+parseFloat(e[i].recharge_diamond_amount);

                }
                $("#count").html('<span style="font-weight:bold ;color:red">'+time+'</span> 共计：<span style="font-weight:bold ;color:red">'+day+'</span>天，耗赠送蓝钻：<span style="font-weight:bold ;color:red">'+free_gold_num+'</span>,耗充值蓝钻：<span style="font-weight:bold; color:red">'+pay_gold_num+'</span>,会长购卡金额：<span style="font-weight:bold; color:red">'+club_recharge_card_amount+'</span>元，黄钻销售金额：<span style="font-weight:bold; color:red">'+recharge_diamond_amount+'</span>元，总开桌数：<span style="font-weight:bold; color:red">'+create_room_num+'</span>');
            }

        });

    });
        $(document).ready(function () {
         /* day_added_user  新增
            day_active_user 日活
            create_room_num 开桌
            create_room_num_region_detail 地区开桌数
            finish_room_num 完整桌数
            day_active_user_region_detail 有效日活
            create_club_num 新开俱乐部
            dissolve_club_num 解散俱乐部
            diamond 总耗赠钻数
            club_recharge_card_amount 会长购卡金额
            */
        $.jgrid.defaults.styleUI = 'Bootstrap';
        $("#table_list_1").jqGrid({
            // url:'__URL__/area_data',
            // postData:{},
            // datatype: "json",
            data: mydata,
            datatype: "local",
            height: 500,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 20,
            rowList: [20,50,100],
            colNames: ['日期', '总新增', '总日活', '总开桌数', '区域开桌', '区域完成桌', '区域日活', '区域有效','新开亲友圈', '解散亲友圈', '区域耗赠钻数', '区域耗充钻数','会长买卡金额','黄钻销售金额'],
            colModel: [
                {
                    name: 'datetime',
                    index: 'datetime',
                    sorttype: "int",
                    align:"center"
                },
                {
                    name: 'day_added_user',
                    index: 'day_added_user',
                    align:"center"
                },
                {
                    name: 'day_active_user',
                    index: 'day_active_user',
                    align:"center"
                },
                {
                    name: 'create_room_num',
                    index: 'create_room_num',
                    align:"center"
                },
                {
                    name: 'create_room_num_region_detail',
                    index: 'create_room_num_region_detail',
                    align:"center"
                },
                {
                    name: 'finish_room_num',
                    index: 'finish_room_num',
                    align:"center"
                },
                {
                    name: 'day_active_user_region_detail',
                    index: 'day_active_user_region_detail',
                    align:"center"
                },
                {
                    name: 'valid_active_user_region_detail',
                    index: 'valid_active_user_region_detail',
                    align:"center"
                },
                {
                    name: 'create_club_num',
                    index: 'create_club_num',
                    align:"center"
                },
                {
                    name: 'dissolve_club_num',
                    index: 'dissolve_club_num',
                    align:"center"
                },
                {
                    name: 'reduce_free_gold_num',
                    index: 'reduce_free_gold_num',
                    align:"center"
                },
                {
                    name: 'reduce_pay_gold_num',
                    index: 'reduce_pay_gold_num',
                    align:"center"
                },
                {
                    name: 'club_recharge_card_amount',
                    index: 'club_recharge_card_amount',
                    align:"center"
                },
                {
                    name: 'recharge_diamond_amount',
                    index: 'recharge_diamond_amount',
                    align:"center"
                },

            ],
            pager: "#pager_list_1",
            viewrecords: true,
            loadonce: true,
            hidegrid: false,
            // caption: "地区数据",                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ",

        });
        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
        });
    });

        $(document).ready(function () {

        $.jgrid.defaults.styleUI = 'Bootstrap';
        $("#table_list_2").jqGrid({
            data: mydata,
            datatype: "local",
            height: 500,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 20,
            rowList: [20,50,100],
            colNames: ['亲友ID', '亲友圈名称', '时间', '累计收益', '状态'],
            colModel: [
                {
                    name: 'datetime',
                    index: 'datetime',
                    sorttype: "int",
                    align:"center"
                },
                {
                    name: 'day_added_user',
                    index: 'day_added_user',
                    // sorttype: "date",
                    // formatter: "date",
                    align:"center"
                },
                {
                    name: 'valid_active_user',
                    index: 'valid_active_user',
                    // sorttype: "float",
                    // formatter: "number",
                    align:"center"
                },
                {
                    name: 'valid_active_user',
                    index: 'valid_active_user',
                    align:"center"
                },
                {
                    name: 'valid_active_user',
                    index: 'valid_active_user',
                    align:"center"
                }
            ],
            pager: "#pager_list_2",
            viewrecords: true,
            loadonce: true,
            caption: "亲友圈",
            hidegrid: false
        });
        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
        });
    });
    laydate.render({
        elem: '#time',
        range: true
    });
</script>
</body>

</html>